package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.bean.CarBean
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_car_item.view.*

/**
 * Created by Administrator on 2018/11/16/016.
 * 作者：刘洋
 */
class CarKAdapter(var context: Context, var list: MutableList<CarBean>) : BaseAdapter()  {
    var minflater: LayoutInflater = LayoutInflater.from(context)
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v :View
        var h : ViewHolder
        if(convertView==null){
            v = minflater.inflate(R.layout.lv_car_item,null)
            h = ViewHolder(v)
            v.tag=h
        }else{
            v = convertView
            h = v.tag as ViewHolder
        }
        var bean = list[position]
        Myutil.settv(bean.CarNumber,h.TvCarNumle)
        Myutil.settv(bean.location,h.TvLocation)
        Myutil.settv(bean.car_name,h.TvCarName)
        Myutil.settv(bean.fullcarload,h.TvFullcarload)
        return v
    }

    override fun getItem(position: Int): Any {
        return list[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        return  list.size
    }
    class ViewHolder(var v : View){
        var TvCarNumle = v.TvCarNumle
        var TvCarName = v.TvCarName
        var TvLocation = v.TvLocation
        var TvFullcarload = v.TvFullcarload

    }
}